class Solution
{
public:
    int matchPlayersAndTrainers(vector<int> &players, vector<int> &trainers)
    {
        sort(players.begin(), players.end());
        sort(trainers.begin(), trainers.end());
        int playerId = 0;
        int trainerId = 0;
        while (playerId < players.size() && trainerId < trainers.size())
        {
            if (players[playerId] <= trainers[trainerId])
            {
                ++playerId;
            }
            ++trainerId;
        }
        return playerId;
    }
};